package cn.xfdzx.android.apps.shop.presenter;

import cn.xfdzx.android.apps.shop.base.BasePresenter;
import cn.xfdzx.android.apps.shop.bean.BaseObjectBean;
import cn.xfdzx.android.apps.shop.bean.ProcurementInfoBeen;
import cn.xfdzx.android.apps.shop.bean.PurchaseSubmitBeen;
import cn.xfdzx.android.apps.shop.bean.PurchaseSubmitEditBeen;
import cn.xfdzx.android.apps.shop.contract.ProcurementConfimListContract;
import cn.xfdzx.android.apps.shop.contract.ProcurementInfoContract;
import cn.xfdzx.android.apps.shop.model.ProcurementConfimListModel;
import cn.xfdzx.android.apps.shop.model.ProcurementInfoModel;
import cn.xfdzx.android.apps.shop.net.RxScheduler;
import io.reactivex.functions.Consumer;

/**
 * @author azheng
 * @date 2018/6/4.
 * Description：
 */
public class ProcurementInfoPresenter extends BasePresenter<ProcurementInfoContract.View> implements ProcurementInfoContract.Presenter {

    private ProcurementInfoContract.Model model;

    public ProcurementInfoPresenter() {
        model = new ProcurementInfoModel();
    }





    @Override
    public void procurementInfo() {
        //View是否绑定 如果没有绑定，就不执行网络请求
        if (!isViewAttached()) {
            return;
        }
        mView.showLoading();
        model.procurementInfo()
                .compose(RxScheduler.<ProcurementInfoBeen>Flo_io_main())
                .as(mView.<ProcurementInfoBeen>bindAutoDispose())
                .subscribe(new Consumer<ProcurementInfoBeen>() {
                    @Override
                    public void accept(ProcurementInfoBeen bean) throws Exception {
                        mView.onProcurementInfoSuccess(bean);
                        mView.hideLoading();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        mView.onError(throwable);
                        mView.hideLoading();
                    }
                });
    }
}
